package com.yami.shop.sys.api.controller;

import com.yami.shop.common.annotation.SysLog;
import com.yami.shop.common.i18n.I18nMessage;
import com.yami.shop.common.i18n.LanguageEnum;
import com.yami.shop.service.SysConfigService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * 系统配置信息
 * @author yami
 */
@RestController
@RequestMapping("/sys/config")
public class SysConfigController {

    @Autowired
    private SysConfigService sysConfigService;

    @ApiOperation(value = "获取服务条款信息", notes = "获取服务条款信息")
    @GetMapping("/info/serviceTerms")
    public ResponseEntity<String> serviceTerms(){
        Integer dbLang = I18nMessage.getDbLang();
        if(Objects.equals(LanguageEnum.LANGUAGE_EN.getLang(), dbLang)) {
            return ResponseEntity.ok(sysConfigService.getValue("SERVICE_TERMS_CONFIG_EN"));
        }
        return ResponseEntity.ok(sysConfigService.getValue("SERVICE_TERMS_CONFIG_CN"));
    }

    @ApiOperation(value = "获取隐私策略信息", notes = "获取隐私策略信息")
    @GetMapping("/info/servicePolicy")
    public ResponseEntity<String> servicePolicy(){
        Integer dbLang = I18nMessage.getDbLang();
        if(Objects.equals(LanguageEnum.LANGUAGE_ZH_CN.getLang(), dbLang)) {
            return ResponseEntity.ok(sysConfigService.getValue("SERVICE_POLICY_CONFIG_CN"));
        }
        return ResponseEntity.ok(sysConfigService.getValue("SERVICE_POLICY_CONFIG_EN"));
    }

}
